<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新闻资讯</title>
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/static/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="/static/layui-v2.6.8/layui/layui.js"></script>
    <link rel="stylesheet" href="/static/layui-v2.6.8/layui/css/layui.css">
    <style>
        .layui-form-selected dl {
            z-index: 1000;
        }
    </style>
</head>

<body>
    <?php
    include "../../fun.php";
    $db=conndb();
    isLogin();
    ?>
    <div style="padding-top:10px">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">类别</label>
                <div class="layui-input-block" style="width:200px">
                    <?php echo select_trees(17, $db, 0, "sortid") ?>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">标题名称</label>
                <div class="layui-input-block" style="width:500px">
                    <input type="text" name="news_name" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">内容</label>
                <div class="layui-input-block">
                    <script id="editor" name="content" type="text/plain" style="width:1024px;height:500px;"></script>
                    <script>
                        UE.getEditor('editor');
                    </script>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">添加时间</label>
                <div class="layui-input-block" style="width:500px">
                <!-- date("Y-m-d H:i:s") 获取当前时间并格式化 -->
                    <input type="text" class="layui-input" name="time" id="time" value="<?php echo date("Y-m-d H:i:s"); ?>">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
                </div>
            </div>
        </form>
    </div>
    
    <script>
        layui.use(['form','jquery','laydate'], function(){
            var form = layui.form//表单提交
            ,$=layui.jquery
            ,laydate = layui.laydate;//时间日期组件
  
            //监听提交
            form.on('submit(formDemo)', function(data){
                // layer.msg(JSON.stringify(data.field));
                $.ajax({
                    method:"post",
                    url: "./save.php",
                    data: data.field,
                    dataType: "json",
                    success: function (res) {
                        if (res.code==0) {
                            layer.msg(res.msg,{icon:1,time:2000},function () {
                                parent.location.href='./index.php';
                            })
                        }
                    }
                });
                return false;
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#time' //指定元素
                ,type: 'datetime'//日期时间   年月日时分秒
                // ,type: 'time'//时间   时分秒 
                // ,type: 'date'//日期时间   年月日 默认
            });
        });
    </script>

</body>

</html>